import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Calendar;
import java.util.Date;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Popup {
	private JFrame f;
	private JButton JByes;
	private JTextField title, mailT;
	private JTextArea content;
	private JLabel jl, jl2, jl3, selectDateL, selectTimeL, hourL, minL, secL, waysL, mailL;
	private JPanel jp1, jp2, jp3, jp4;
	private String[] hour;
	private String[] min;
	private String[] sec;
	
	//������ϸ����
	String noteTitle, noteContent, mail, id;
	Timestamp t;

	public Popup(Timestamp time) {
		String[] detail;
		try {
			//��ȡ��ϸ��Ϣ
			DatabaseCtrl.init();
			detail = DatabaseCtrl.getDetail(time);
			noteTitle = detail[0];
			noteContent = detail[1];
			mail = detail[2];
			id = detail[3];
						
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		f = new JFrame("���Ѳ�");
		JByes = new JButton("ȷ��");
		JByes.addActionListener(new Lis());
		JByes.setSize(new Dimension(100, 30));
		title = new JTextField(noteTitle);
		mailT = new JTextField(mail);
		content = new JTextArea(noteContent);
		jl = new JLabel("��������");
		jl2 = new JLabel("���⣺");
		jl3 = new JLabel("���ݣ�");
		
		jp1 = new JPanel();
		jp2 = new JPanel();
		jp3 = new JPanel();
		jp4 = new JPanel(new GridLayout(2, 3));
	}
	
	public void launch() {
		f.setSize(400, 400);
		f.setLayout(new GridLayout(6, 1, 10, 10));
		f.invalidate();
		f.add(jl);
		f.add(jl2);
		f.add(title);
		f.add(jl3);
		content.setLineWrap(true);
		f.add(new JScrollPane(content));

		jp1.add(JByes);
		f.add(jp1);
		
		f.setVisible(true);
		f.setLocationRelativeTo(null);
		//f.setResizable(false);
		f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		
	}
	
	class Lis implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			Object source = e.getSource();
			if(source == JByes) {
				f.dispose();
			}
		}
		//��date��ת��ΪCalendar��
		  public Calendar dateToCalendar(Date date) {
		        Calendar calendar = Calendar.getInstance();
		        calendar.setTime(date);
		        return calendar;
		    }	
	}

	public static void main(String[] args) {
		//���ѱ���
		Timestamp t = new Timestamp(System.currentTimeMillis());
		Popup myNote = new Popup(t);
		myNote.launch();

	}

}